#include<bits/stdc++.h>
using namespace std;
struct node {
    int d, v, a;
} arr[100005];
int T, n, m, l, v, p[100005], cnt1, cnt2;
int main () {
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    scanf("%d", &T);
    while (T--) {
        cnt1 = cnt2 = 0;
        scanf("%d%d%d%d", &n, &m, &l, &v);
        for (int i = 1; i <= n; i++) scanf("%d%d%d", &arr[i].d, & arr[i].v, &arr[i].a);
        for (int i = 1; i <= m; i++) scanf("%d", &p[i]);
        for (int i = 1; i <= m; i++) {
            double f = sqrt(pow(arr[i].v, 2) + 2.0 * arr[i].a * (arr[i].v * 1 + 0.5 * arr[i].a * 1));
            if (f > 1.0 * v) cnt1++, cnt2++;
        }
        cout << cnt1 + 1 << " " << cnt2 + 1 << '\n';
    }
}
